package com.lenovo.rc.sil.wangdwa.learning;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;


public class ServiceDemoActivity extends Activity implements OnClickListener {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        Button btnStart = (Button)findViewById(R.id.BTN_START_SERVICE);
        btnStart.setOnClickListener(this);
        Button btnStop = (Button)findViewById(R.id.BTN_STOP_SERVICE);
        btnStop.setOnClickListener(this);
    }

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch(v.getId()){
		case R.id.BTN_START_SERVICE:
			doStart();
			break;
		case R.id.BTN_STOP_SERVICE:
			doStop();
			break;
		}
	}

	private void doStop() {
		// TODO Auto-generated method stub
		Log.d(getClass().getName(), "doStop()");
		
		Intent theService = new Intent(this, DummyService.class);
		this.stopService(theService);
		
	}

	private void doStart() {
		// TODO Auto-generated method stub
		Log.d(getClass().getName(), "doStart()");
		
		Intent theService = new Intent(this, DummyService.class);
		this.startService(theService);
		
		
	}
}